package com.zzb.spring.aop.impl.xml;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {
	public static void main(String[] args) {
		//1. 创建 IOC 容器
		ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext-xml.xml");
		
		//2. 从 IOC 容器中获取 bean 实例
		ArithmeticCalculator arithmeticCalculator = ctx.getBean(ArithmeticCalculator.class);
		System.out.println(arithmeticCalculator.getClass().getName());//能打印出来是一个代理对象
		
		int result = arithmeticCalculator.add(3, 6);
		System.out.println("result = " + result);
		
//		result = arithmeticCalculator.div(4, 0);//除以0 会报错 但是还是会先打印日志
//		System.out.println("result = " + result);
		
//		result = arithmeticCalculator.div(4, 2);//验证 返回通知
//		System.out.println("result = " + result);
	}
	
}
